package net.borlis.server.properties;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

/**
 * Created by borlis on 26.12.2014.
 */
public class JdbcProperties {

    private String url;
    private String driverName;
    private String username;
    private String password;

    public JdbcProperties() {
        try {
            PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration("props/jdbc.properties");
            this.driverName = propertiesConfiguration.getString("database.driver");
            this.url = "jdbc:" + propertiesConfiguration.getString("database.type") + "://" +
                    propertiesConfiguration.getString("database.server") + ":"
                    + propertiesConfiguration.getString("database.port") + "/"
                    + propertiesConfiguration.getString("database.name");
            this.username = propertiesConfiguration.getString("database.user");
            this.password = propertiesConfiguration.getString("database.password");
        } catch (ConfigurationException e) {
            e.printStackTrace();
        }
    }

    public String getUrl() {
        return url;
    }

    public String getDriverName() {
        return driverName;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }
}
